package com.healthcloud.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.healthcloud.dao.ExternalMapper;
import com.healthcloud.dao.HospDrAssoMapper;
import com.healthcloud.entity.BluetoothBean;
import com.healthcloud.entity.CookBean;
import com.healthcloud.entity.DoctorAndPatientsRelation;
import com.healthcloud.entity.DrugBean;
import com.healthcloud.entity.HospDrAsso;
import com.healthcloud.service.ExternalService;
import com.healthcloud.utils.PageParam;
import com.healthcloud.vo.PatientVo;

@Service
@Transactional
public class ExternalServiceImpl implements ExternalService{
	
	@Autowired
	private ExternalMapper mapper;
	
	@Autowired
	private HospDrAssoMapper hdaMapper;

	@Override
	public List<BluetoothBean> getBluetoothPackage(BluetoothBean entity) {

		return mapper.getBluetoothPackage(entity);
	}

	@Override
	public List<CookBean> getAllCook(String id,PageParam page) {

		return mapper.getAllCook(id,page);
	}

	@Override
	public List<DrugBean> getAllDrug(String id, PageParam page) {

		return mapper.getAllDrug(id,page);
	}

	@Override
	public List<PatientVo> getPatients(String docId) {
		HospDrAsso entity1 = new HospDrAsso();
		entity1.setDrId(Long.valueOf(docId));
		List<HospDrAsso> list1 = hdaMapper.findByEntityAll(entity1);
		DoctorAndPatientsRelation entity = new DoctorAndPatientsRelation();
		if(list1!=null&&list1.size()>0){
			HospDrAsso hda = list1.get(0);
			entity.setHospitalId(hda.getHospId());
		}
		
		return mapper.getPatients(entity);
	}

}
